package com.qf.controller;/*
 *徐韬
 *2021/11/5
 *14:28
 */

import com.github.pagehelper.PageInfo;
import com.qf.cache.acountCache;
import com.qf.dto.R;
import com.qf.pojo.TAcountRecord;
import com.qf.service.acountService;
import io.swagger.annotations.Api;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cglib.core.Converter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/aount")
@Api(tags = "订单信息表")
public class acountController {
    private acountCache acountCache;
@Autowired
    public void setAcountCache(com.qf.cache.acountCache acountCache) {
        this.acountCache = acountCache;
    }

    private acountService acountService;
@Autowired
    public void setAcountService(com.qf.service.acountService acountService) {
        this.acountService = acountService;
    }
    @GetMapping("/showAll")
    public R showAll(@RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "2") Integer pageSize){
        PageInfo<TAcountRecord> pageInfo = acountService.showAll(pageNum, pageSize);
        return R.setOk(pageInfo);
    }
    @GetMapping("/showById/{id}")
    public R showById(@PathVariable Long id){
        TAcountRecord byId = acountCache.getById(id);

        return R.setOk(byId);

    }
    @PostMapping("/add")
    public R add(@RequestBody TAcountRecord tAcountRecord){
        acountService.addTacont(tAcountRecord);
        return R.setOk();
    }
    @PostMapping("/update")
    public R update(Long id, String orderid, Long clientId, Long paidValue, @DateTimeFormat(pattern = "yyyy-mm-dd") Date createTime,@DateTimeFormat(pattern = "yyyy-mm-dd") Date payTime, Long paymentId,String paymentOrder, String paymentInfo){
    TAcountRecord tAcountRecord = new TAcountRecord(id,orderid,clientId,paidValue,createTime,payTime,paymentId,paymentOrder,paymentInfo);
     acountService.update(tAcountRecord);
     return R.setOk();

    }
    @DeleteMapping("/delete")
    public R deleteByIds(@RequestBody Map map){
        List<Integer> ids = (List<Integer>)map.get("ids");
        acountService.deletedByIds(ids);
        return R.setOk();


    }


}
